package ops.view.forms.component;

import javax.swing.JComponent;
import javax.swing.JPasswordField;

public class PasswordInput extends FormInput {

	private JPasswordField field;
	
	public PasswordInput(String label) {
		super(label, false);
	}
	
	public PasswordInput(String label, int size) {
		super(label, false);
		
		field = new JPasswordField(size);
	}
	
	public PasswordInput(String label, int size, boolean required) { 
		super(label, required);
		
		field = new JPasswordField(size);
	}

	@Override
	public Object getInputValue() {
		return new StringBuilder().append(field.getPassword()).toString();
	}

	@Override
	public JComponent getInputComponent() {
		return field;
	}
	
	@Override
	public void setInputValue(Object value) {
		field.setText(value.toString());
	}
	
	@Override
	public void clearInput() {
		field.setText(null);
	}
}
